#数据性能，
#列表

from timeit import Timer, timeit
import pandas as pd
import matplotlib.pyplot as plt


def test1():
    l = []
    for i in range(1000):
        l = l + [i]

def test2():
    l = []
    for i in range(1000):
        l.append(i)

def test3():
    l = [i for i in range(1000)]

def test4():
    l = list(range(1000))

t1 = Timer("test1()", "from __main__ import test1")
print("concat %f secongs\n" % t1.timeit(number = 1000))

t2 = Timer("test2()", "from __main__ import test2")
print("concat %f secongs\n" % t2.timeit(number = 1000))

t3 = Timer("test3()", "from __main__ import test3")
print("concat %f secongs\n" % t3.timeit(number = 1000))

t4 = Timer("test4()", "from __main__ import test4")
print("concat %f secongs\n" % t4.timeit(number = 1000))

pop0 = Timer("x.pop(0)", 'from __main__ import x')
pop1 = Timer("x.pop", 'from __main__ import x')


pz_lst = []
p1_lst = []

for i in range(1000000, 10000001, 1000000):
    x = list(range(i))
    pt0 = pop0.timeit(number=1000)
    pz_lst.append(pt0)
    x = list(range(i))
    pt1 = pop1.timeit(number=1000)
    p1_lst.append(pt1)

df = pd.DataFrame({'pz':pz_lst,'p1':p1_lst})
print(df)

plt.scatter(x=df.index, y=df['pz'])
plt.scatter(x=df.index, y=df['p1'])
plt.show()